import request from '@/utils/request'
export function getGoodsList({ putaway, condition, kind, is_vip, page	}) {
  return request({
    url: '/api/back/shop/commodityList',
    method: 'get',
    params: { is_serve: 2, putaway, condition, kind, is_vip, page, per_page: 8 }
  })
}
// "name": "测试商品名称1",//商品名称
// "kind": "20",//分类ID
// "brand": "1",//品牌ID
// "cost": "200",//成本价格
// "original_price": "300",//原价
// "price": "150",//价格
// "discount_price": "30",//折扣价
// "inventory": "15",//库存
// "inventory_caution": "12",//库存预警
// "commodity_img": [
//         'http://baidu.com',
//     ],//数组格式，轮播图
// "img_show": "",//封面图
// "commodity_video": "",//视频
// "quota": "0",//单人限额（限购）
// "parameter": '[{"name":"\u578b\u53f7","detail":2000}]',//参数(二维数组)
// 添加商品
/* 第一步添加 */
export function addGoodsStepOne({ name, item_no, kind, brand, cost, original_price, price, discount_price, inventory, inventory_caution, commodity_img, img_show, commodity_video, quota, parameter }) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'post',
    data: { name, item_no, kind, brand, cost, original_price, price, discount_price, inventory, inventory_caution, commodity_img, img_show, commodity_video, quota, parameter },
    params: { type: 'one', is_serve: 2 }
  })
}
/* 第二步添加 */
export function addGoodsStepTwo({ id, putaway, introduce }) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'post',
    data: { id, putaway, introduce },
    params: { type: 'four' }
  })
}
/* 第一步获取 */
export function getGoodsDetailStepOne(id) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'get',
    params: { type: 'oneSave', id }
  })
}
/* 第一步修改 */
export function editGoodsStepOne({ name, item_no, kind, brand, cost, original_price, price, discount_price, inventory, inventory_caution, commodity_img, img_show, commodity_video, quota, parameter, id }) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'post',
    data: { name, item_no, kind, brand, cost, original_price, price, discount_price, inventory, inventory_caution, commodity_img, img_show, commodity_video, quota, parameter },
    params: { type: 'oneSave', id }
  })
}
/* 第二步获取 */
export function getGoodsStepTwo(id) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'get',
    params: { type: 'fourSave', id }

  })
}
// 商品类目
export function getClassificationList() {
  return request({
    url: '/api/back/shop/commodityKind',
    method: 'get',
    params: { type: 'list', status: 1 }
  })
}
// 品牌
export function getBrandList() {
  return request({
    url: '/api/back/shop/commodityBrand',
    method: 'get',
    params: { type: 'list' }
  })
}
// 修改商品
export function editGoodsItem({ id, name, is_putaway, price, original_price, sort }) {
  return request({
    url: '/api/back/shop/commoditySave',
    method: 'post',
    data: { id, name, is_putaway, price, original_price, sort },
    params: { type: 'save' }
  })
}
// 删除接口
export function deleteGoodsItem(id) {
  return request({
    url: '/api/back/shop/commodityAdd',
    method: 'post',
    data: { id },
    params: { type: 'delete' }
  })
}
